var sessionInfo = function() {
  this.inactive = false;
  this.overlay = null; 
}

//Add by brian 2013.03.07 :: Callback event to change topic in session info table
function GTKonopicChanged(event) {
  $("#topic").html(gapi.hangout.getTopic());
}

//Add by brian 2013.03.08 :: query speaker in hangout participant list
function show_speaker() {
	var participants = gapi.hangout.getParticipants();
	for (var index in participants) {
    	var participant = participants[index];
	}
	console.log("speaker: " + participant.person.displayName);
	return participant.person.displayName;
}

sessionInfo.prototype.init = function() {
  //Register related event function
  gapi.hangout.onTopicChanged.add(GTKonopicChanged);
  
  var container = $('#content-wrap4');
  container.html('');
  
  //Create a participants list header 
  container.append('<legend><h3>Conference Info</h3></legend>');
  container.append('<table cellspacing="0" cellpadding="0">');
  container.append('  <tr>');
  container.append('    <td title="title">Topic:</td>');
  container.append('    <td id="topic" title="title">Null</td>');
  container.append('  </tr>');
  container.append('  <tr>');
  container.append('    <td title="title">Speaker:</td>');
  container.append('    <td id="speaker" title="title">Null</td>');
  container.append('  </tr>');
  container.append('  <tr>');
  container.append('    <td title="Provide this link to participants to load GCVC by default on entering the Hangout. Right-click this link and select Copy link address, then paste the link into your invitation post.">URL:</td>');
  container.append('    <td>');
  container.append('	<a id="HangoutUrl" name="HangoutUrl" target="_blank">Link</a>');
  container.append('	</td>');
  container.append('  </tr>');
  container.append('  <tr>');
  container.append('    <td title="title">Hangout Id:</td>');
  container.append('    <td id="HangoutId" title="title">Null</td>');
  container.append('  </tr>');
  container.append('</table>');

  //Get data from google hangout and show data
  console.log("version 1");
  console.log(window.displayIndex);  
  $(document).ready(function(){
	$("#topic").html(gapi.hangout.getTopic());
	$("#speaker").html(show_speaker());
	$("#HangoutUrl").attr('href', gapi.hangout.getHangoutUrl());
	$("#HangoutId").html(gapi.hangout.getHangoutId());
  });
}
